package com.yic.module.device.dal.mysql.inspectionPlanJob;

import java.util.*;

import cn.hutool.core.util.ObjectUtil;
import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.device.dal.dataobject.inspectionPlanJob.InspectionPlanJobDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.device.controller.admin.inspectionPlanJob.vo.*;

/**
 * 巡检计划与任务关联 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface InspectionPlanJobMapper extends BaseMapperX<InspectionPlanJobDO> {

    default PageResult<InspectionPlanJobDO> selectPage(InspectionPlanJobPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanJobDO>()
                .eqIfPresent(InspectionPlanJobDO::getJobId, reqVO.getJobId())
                .eqIfPresent(InspectionPlanJobDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(InspectionPlanJobDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(InspectionPlanJobDO::getCreateTime, reqVO.getCreateTime())
                .inSql(ObjectUtil.isNotNull(reqVO.getType()),InspectionPlanJobDO::getPlanId,String.join(",",reqVO.getPlanIdList()))
                .orderByDesc(InspectionPlanJobDO::getId));
    }

    default List<InspectionPlanJobDO> selectList(InspectionPlanJobExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InspectionPlanJobDO>()
                .eqIfPresent(InspectionPlanJobDO::getJobId, reqVO.getJobId())
                .eqIfPresent(InspectionPlanJobDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(InspectionPlanJobDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(InspectionPlanJobDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionPlanJobDO::getId));
    }

}
